package com.lujianfei.netease_android_canvas.ui

import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.lujianfei.netease_android_canvas.R
import com.lujianfei.netease_android_canvas.widget.LoadingLogo


class MastAnimActivity : AppCompatActivity(),View.OnClickListener {

    private var index: Int = 0
    var loadingLogo: LoadingLogo?= null
    var colors = arrayOf(0xffff0000,0xff00ff00,0xff0000ff)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_mask_anim)
        loadingLogo = findViewById(R.id.loadingLogo)
        findViewById<View>(R.id.start).setOnClickListener(this)
        findViewById<View>(R.id.end).setOnClickListener(this)
        findViewById<View>(R.id.change).setOnClickListener(this)
    }

    override fun onClick(p0: View?) {
        when(p0?.id) {
            R.id.start->{
                loadingLogo?.startLoading()
            }
            R.id.end->{
                loadingLogo?.stopLoading()
            }
            R.id.change->{
                loadingLogo?.postColor(colors[index % colors.size].toInt())
                ++index
            }
        }

    }
}
